<template>
  <a-card :bordered="false">
    <component @onEdit="handleEdit" @onGoBack="handleGoBack" :customerId="customerId" :is="currentComponet"/>
  </a-card>
</template>

<script>
  // 动态切换组件
  import List from '@/perm/views/qywx/sop/sopManage'
  import Edit from '@/perm/views/qywx/sop/sopEdit'

  export default {
    name: 'SopPage',
    components: {
      List,
      Edit
    },
    data () {
      return {
        currentComponet: 'List',
        customerId: ''
      }
    },
    methods: {
      handleEdit (customerId) {
        this.customerId = customerId
        this.currentComponet = 'Edit'
        this.$router.push({
              path: '/qywx/khqsop?type=detail'
          })
      },
      handleGoBack () {
        this.customerId = ''
        this.currentComponet = 'List'
      }
    },
    watch: {
      '$route' () {
        const type = this.$route.query.type
        if (type !== 'detail') {
          this.record = ''
          this.currentComponet = 'List'
        }
      }
    }
  }
</script>
